﻿create PROCEDURE Sync.SP_Settings_SelectChanges
@LastRowVersion rowversion,
@FilterdColumn UNIQUEIDENTIFIER
AS 
BEGIN 
	SELECT 
        g.[ID],g.[Key],g.[Value],g.[CommitteeID],
		t.IsDeleted,
		t.LastUpdatedDate
	FROM [dbo].[Settings] g RIGHT JOIN Sync.Settings_Tracking t  
    ON  g.[ID] = t.[ID]
	WHERE ((@LastRowVersion IS NULL OR t.Version > @LastRowVersion)
        AND (@FilterdColumn IS NULL OR g.CommitteeID = @FilterdColumn))
    END